home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / detach.lha / Detatch.s < prev    next >
Encoding:
Text File  |  1980-01-01  |  944 b   |  51 lines

  1.  
  2.     ; Written By Shagratt/LSD
  3.     
  4.     ; this creates a process of the other bit of code (after "section 
  5.     ; main") and then this first bit quits, returning control to the
  6.     ; CLI and having to other code still running.
  7.  
  8.     ; Must be executed from the CLI as if relies on hunk structure.
  9.     
  10.     section    detatch,code    
  11.  
  12. Code:    Lea    DosName,A1
  13.     Moveq    #0,D0
  14.     jsr    -552(a6)            ;OpenLibrary
  15.     Move.l     D0,_DOSBase
  16.     Beq    .error
  17.  
  18.     lea    code,a0
  19.     move.l    -4(a0),d3
  20.     move.l    d3,segaddress
  21.     move.l    #0,-4(a0)
  22.     
  23.     move.l    _DOSBase,a6
  24.     move.l    #myname,d1
  25.     move.l    #0,d2
  26.     move.l    #4000,d4
  27.     jsr    -138(a6)            ; create proc
  28.  
  29. .error    clr.l    d0    
  30.     rts
  31.  
  32.     *---------------------------------*
  33.  
  34.     Section    Main,Code
  35.  
  36. Start:    move.w    $dff006,$dff180
  37.     btst    #6,$bfe001
  38.     bne    Start
  39.  
  40.     move.l    _DOSBASE,a6            ; remove code
  41.     move.l    segaddress,d1        ; from memory.
  42.     jmp    -156(a6)            ; unloadseg
  43.  
  44.     *---------------------------------*
  45.  
  46. _DOSBASE:    dc.l    0
  47. DosName:    dc.b    "dos.library"
  48. segaddress:    dc.l    0
  49. myname:    dc.b    "MyTask",0
  50.  
  51.